import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {SharedModule} from '../shared.module';
import {MODAL_WIDTH} from '../../const'
import {Building} from '../../types/resp/Building';

@Component({
  selector: 'building-view',
  imports: [
    SharedModule
  ],
  templateUrl: './building-view.component.html',
  standalone: true
})
export class BuildingViewComponent implements OnInit {
  buildingForm!: FormGroup;
  isVisible: boolean = false
  title: string = '楼栋信息详情'
  modalWidth: string = MODAL_WIDTH

  constructor(
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.buildingForm = this.fb.group({
      buildingName: [''],
      address: [''],
      floorCount: [0],
      roomCount: [0],
      createTime: [''],
      modifyTime: [''],
    })
  }

  onBack() {
    this.isVisible = false
  }

  display(building: Building) {
    this.isVisible = true
    this.buildingForm.patchValue(building);
    this.buildingForm.disable();
  }
}
